package com.course.business.controller.web;

import com.course.server.domain.Travel;
import com.course.server.dto.PageDto;
import com.course.server.dto.ResponseDto;
import com.course.server.dto.TravelDto;
import com.course.server.dto.TravelPageDto;
import com.course.server.enums.TravelStatusEnum;
import com.course.server.service.TravelService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController("webTravelController")
@RequestMapping("/web/travel")
public class TravelController {

    private static final Logger LOG = LoggerFactory.getLogger(TravelController.class);
    public static final String BUSINESS_NAME = "游玩";

    @Resource
    private TravelService travelService;

    /**
     * 列表查询，查询最新的3门已发布的课程
     */
    @GetMapping("/list-new")
    public ResponseDto listNew() {
        PageDto pageDto = new PageDto();
        pageDto.setPage(1);
        pageDto.setSize(3);
        ResponseDto responseDto = new ResponseDto();
        List<TravelDto> travelDtoList = travelService.listNew(pageDto);
        responseDto.setContent(travelDtoList);
        return responseDto;
    }

    /**
     * 列表查询
     */
    @PostMapping("/list")
    public ResponseDto list(@RequestBody TravelPageDto pageDto) {
        ResponseDto responseDto = new ResponseDto();
        pageDto.setStep(TravelStatusEnum.PUBLISH.getCode());
        travelService.list(pageDto);
        responseDto.setContent(pageDto);
        return responseDto;
    }
//
//    @GetMapping("/find/{id}")
//    public ResponseDto findCourse(@PathVariable String id) {
//        LOG.info("查找课程开始：{}", id);
//        ResponseDto responseDto = new ResponseDto();
//        CourseDto courseDto = courseService.findCourse(id);
//        responseDto.setContent(courseDto);
//        LOG.info("查找课程结束：{}", responseDto);
//        return responseDto;
//    }
}
